﻿using System;
using System.Collections.Generic;
using System.Text;
using dtSearch.Engine;

namespace DTSearchHelper
{
    public class IndexStatusHandler:IIndexStatusHandler
    {

        private AbortValue abortValue = AbortValue.Continue;
        public AbortValue AbortValue
        {
            get { return abortValue; }
            set { abortValue = value; }
        }

        public delegate void ProgressDelegate(object Sender, ProgressChanegedEventArgs e);
        public event ProgressDelegate ProgressChaneged;

        public IndexStatusHandler()
        {
        }

        #region IIndexStatusHandler Members

        public AbortValue CheckForAbort()
        {
            return abortValue;
        }

        public void OnProgressUpdate(IndexProgressInfo info)
        {
            if (this.ProgressChaneged != null)
            {
                ProgressChanegedEventArgs e=new ProgressChanegedEventArgs (info);
                this.ProgressChaneged(this, e);
            }
        }

        #endregion
    }

    public class ProgressChanegedEventArgs
    {
        private readonly IndexProgressInfo myInfo;

        public IndexProgressInfo MyInfo
        {
            get { return myInfo; }
        }

        public ProgressChanegedEventArgs(IndexProgressInfo info)
        {
            this.myInfo = info;
        }
    }
}
